<?php

namespace App\Services;

use App\Models\User;
use Illuminate\Support\Facades\Hash;

class AuthService
{
    public function login($data,$api=false)
    {
        $email = $data['email'] ?? "";
        $password = $data['password'] ?? "";

        if(!$email || !$password){
            return null;
        }
        $user = User::where('email',$email)->first();

        if(Hash::check($password,$user->password)){
            return $user;
        }
        return null;
    }
}
